# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: David Runge <dvzrv@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>
# Contributor: Alexander Fehr <pizzapunk gmail com>
# Contributor: William Rea <sillywilly@gmail.com>
# Contributor: Daniel J Griffiths <ghost1227@archlinux.us>

pkgname=xapian-core
pkgver=1.4.22
pkgrel=1
epoch=1
pkgdesc='Open source search engine library.'
arch=('x86_64')
url="https://www.xapian.org/"
license=('GPL2')
makedepends=('util-linux')
depends=('bash' 'gcc-libs' 'glibc' 'zlib')
provides=('libxapian.so')
# xapian config requires libxapian.la
options=('libtool')
source=("https://oligarchy.co.uk/xapian/${pkgver}/${pkgname}-${pkgver}.tar.xz"{,.asc})
sha512sums=('60d66adbacbd59622d25e392060984bd1dc6c870f9031765f54cb335fb29f72f6d006d27af82a50c8da2cfbebd08dac4503a8afa8ad51bc4e6fa9cb367a59d29'
            'SKIP')
b2sums=('f4aec86cd5f63f6f1825a4f8f427ea23be2092ffb4ca11a2fdf20bdf652e7b9f768b1155bcf7ee5e5c5313206c92e1725d1b4d562e3074539a2e8f9901c44f8e'
        'SKIP')
validpgpkeys=('08E2400FF7FE8FEDE3ACB52818147B073BAD2B07') # Olly Betts <olly@debian.org>

prepare() {
  cd "${pkgname}-${pkgver}"
  autoreconf -vfi
}

build() {
  cd "${pkgname}-${pkgver}"

  # workaround for test failure in libzim
  #   23/27 search_iterator  FAIL  0.47s  killed by signal 6 SIGABRT
  CXXFLAGS=${CXXFLAGS/-Wp,-D_GLIBCXX_ASSERTIONS}

  ./configure --prefix=/usr
  make
}

check() {
  cd "${pkgname}-${pkgver}"
  make check
}

package() {
  depends+=('libuuid.so')
  cd ${pkgname}-${pkgver}
  make DESTDIR="${pkgdir}" install
  install -vDm 644 {AUTHORS,ChangeLog,HACKING,NEWS,README} \
    -t "${pkgdir}/usr/share/doc/${pkgname}"
}
